<?php
namespace App\User\Services;

use App\Services\CommonBaseService;
use App\User\Models\UserBindAppModel;

class UserBindAppService extends CommonBaseService
{
    protected $cache = true;

    protected $cacheBucket = 'UserBindApp:';

    protected $tokenBucket = 'SysAppToken:';

    protected $activeBucket = "Active:";

    public function __construct(UserBindAppModel $model)
    {
        $this->model = $model;
    }

    public function getUserBindApp($userId)
    {
       return $this->model->getUserBindApp($userId);
    }

    public function saveUserBindApp($userId, $appId)
    {
        $find = $this->model->getUserBindApp($userId, $appId);
        if(empty($find[0])) {
            $id = $this->model->saveUserBindApp($userId, $appId);
        } else {
            $id = $find[0]['id'];
        }
        return $id;
    }

}
